<%@ page import="sun.misc.BASE64Decoder" %>
<%@ page import="sun.misc.BASE64Encoder" %>
<%@ page import="com.microstrategy.web.Credential" %>
<%@ page import="com.microstrategy.web.objects.WebIServerSession" %>
<%@ page import="net.risesoft.risereport.obj.authorization.presentation.*" %>
<%@ page import="net.risesoft.risereport.obj.authorization.domain.*" %>
<html>
<%
session.removeAttribute("UserInfo");
%>
 <body>
 	<% 
 	/* here will do some check  */
 	try
 	{

  System.out.println(" here will do some check ");
 	     String iName= request.getParameter("iserverUserName");
 	     String iPassword = request.getParameter("iserverUserPwd");
 	     String iServerName = request.getParameter("iserverMachine");
 	     String iProjectName = request.getParameter("iserverProject");
 	     System.out.println(" "+ iName + " " + iPassword + " " + iProjectName + " " + iServerName);
 	     Credential puser = null;  
 	     if("zhs".equalsIgnoreCase(iProjectName)){
 	    	puser =  new Credential("zhk","zhk",iProjectName,iServerName,0);
 	     }else{
 	    	AuthorizationManager am = new AuthorizationManager();
 	  		User user = am.getAuthorizationService().findUserByNameAndPwd(iName, new BASE64Encoder().encode(iPassword.getBytes()));
 	    	puser =  new Credential(user.getMSTRUser(),user.getMSTRUser(),iProjectName,iServerName,0);
 	     }
 	     WebIServerSession iSession = puser.getMSTRSession();
 	     
 	     if(iSession==null) {
 	     	response.sendRedirect("MyLogin.jsp");
 	     } else {
 	      	 session.setAttribute("UserInfo", puser);
 	     
 	         %>
 	     	<form name="hiddenForm" method="post" action="<%=request.getContextPath()%>/servlet/mstrWeb"><!-- ?pg=shared --></form>
 	   			<script language="JavaScript">
           			document.hiddenForm.submit();
           		</script>
 	     	<%
 	     }
 	}
 	catch(Exception e)
 	{
 		out.println(e.toString());
 	}
 	%>
 	       
 </body>
 </html>